/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ge.ktools;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 *
 * @author koka
 */
public class StringUtils
{

    public static List<String> splitString(String s)
    {
        if (s == null)
        {
            return null;
        }
        ArrayList<String> result = new ArrayList<String>();
        String[] ss = s.split(" ");
        for (String str : ss)
        {
            if (str.length() > 0)
            {
                result.add(str);
            }
        }
        if (result.size() == 0)
        {
            return null;
        }
        return result;
    }

    public static boolean containsAllStrings(String source, List<String> parts)
    {
        for (String s : parts)
        {
            if (source.indexOf(s) == -1)
            {
                return false;
            }
        }
        return true;
    }

    public static String toNumbers(String s)
    {

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++)
        {
            if (Character.isDigit(s.charAt(i)) || s.substring(i, i + 1).equals(" "))
            {
                sb.append(s.charAt(i));
            }
        }
        if (sb.length() == 0)
        {
            sb.append(" ");
        } else
        {
            String[] ss = sb.toString().trim().split(" ");
            sb.delete(0, sb.length());
            for (String phone : ss)
            {
                if (phone.length() < 7)
                {
                    sb.append("832");
                }
                sb.append(phone).append("; ");
            }
        }

        return sb.toString();
    }

    public static void main(String[] args)
    {
        String[] ss = " 55 788 999 000   ".trim().split(" ");
        System.out.println("--------------");
        for (String s : ss)
        {
            System.out.println(s);
        }
        System.out.println("--------------");

//
//        String op1 = "mag";
//        String op2 = "geo";
//                String opCode1 = "99";
//        String opCode2 = "77";
//
//        ArrayList l = new ArrayList();
//
//        HashMap<String,String> map = new HashMap<String,String>();
//        map.put("op", op1);
//        map.put("code", opCode1);
//        Calendar cl = Calendar.getInstance();
//        cl.setTimeInMillis(System.currentTimeMillis());
//
//
//        System.out.println(cl.get(Calendar.YEAR));
//        System.out.println(cl.get(Calendar.MONTH) + 1);

    }
}
